from abc import ABC, abstractmethod


class Observer(ABC):
    @abstractmethod
    def update(self, subject):
        pass


class Subject:
    def __init__(self):
        self._observers = []

    def register_observer(self, observer: Observer):
        if observer not in self._observers:
            self._observers.append(observer)
            observer.update(self)

    def unregister_observer(self, observer: Observer):
        if observer in self._observers:
            self._observers.remove(observer)

    def notify_observers(self):
        for observer in self._observers:
            observer.update(self)
